<template>
  <!--<li class="am-g">
    <span class="am-u-sm-offset-1 am-u-sm-2 am-text-right">创建时间:</span>
    <div class="am-u-sm-3">
      <div id="sctime" class="am-input-group date">
        <input size="16" type="text" class="am-form-field" placeholder="  开始时间" readonly>
        <span class="am-input-group-label add-on"><i @click="clear1" class="icon-remove am-icon-close"></i></span>
        <span class="am-input-group-label add-on"><i class="icon-th am-icon-calendar"></i></span>
      </div>
    </div>
    <span class="am-u-sm-2 am-text-right">至:</span>
    <div class="am-u-sm-3">

      <div id="ectime" class="am-input-group date">
        <input size="16" type="text" class="am-form-field" placeholder="  结束时间" readonly>
        <span class="am-input-group-label add-on"><i @click="clear2" class="icon-remove am-icon-close"></i></span>
        <span class="am-input-group-label add-on"><i class="icon-th am-icon-calendar"></i></span>
      </div>

    </div>
    <div></div>
  </li>-->
  <DIV>
  <div class="am-u-md-6">
    <div id="sctime" class="am-input-group date">
    <span class="am-input-group-label " >从：</span>
      <input size="16" type="text" class="am-form-field" placeholder="  开始时间" readonly>
      <span class="am-input-group-label add-on"><i @click="clear1" class="icon-remove am-icon-close"></i></span>
      <span class="am-input-group-label add-on"><i class="icon-th am-icon-calendar"></i></span>
    </div>
  </div>
  <div class="am-u-md-6">
    <div id="ectime" class="am-input-group date">
      <span class="am-input-group-label" >到：</span>
      <input  type="text" class="am-form-field" placeholder="  结束时间" readonly>
      <span class="am-input-group-label add-on"><i @click="clear2" class="icon-remove am-icon-close"></i></span>
      <span class="am-input-group-label add-on"><i class="icon-th am-icon-calendar"></i></span>
    </div>
  </div>
</DIV>
</template>

<script>
  export default {
    name: 'TimeSearch',
    data() {
      return {
        sctime: '',
        ectime: ''
      }
    },
    mounted() {
      let _this = this
      this.$nextTick(() => {
        $('#sctime').datetimepicker({
          language: 'zh-CN',
          showMeridian: true,
          autoclose: true,
          todayBtn: true
        }).on('changeDate', function (ev) {
          _this.sctime = ev.date.valueOf()
        });

        $('#ectime').datetimepicker({
          language: 'zh-CN',
          showMeridian: true,
          autoclose: true,
          todayBtn: true
        }).on('changeDate', function (ev) {
          _this.ectime = ev.date.valueOf()
        });
      })
    },
    watch: {
      sctime(val) {
        this.$emit('setSctime', val)
      },
      ectime(val) {
        this.$emit('setEctime', val)
      }
    },
    methods: {
       clear1 () {
        this.$emit('setSctime', '')
      },
      clear2 () {
        this.$emit('setEctime', '')
      }
    }
  }

</script>